home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: [Help] I can't find my error.
- Date: 26 Feb 1996 03:51:09 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb25205109@qcd.lanl.gov>
- References: <4ggvgr$1b2@aurora.engr.LaTech.edu> <4gqutt$i1f@umbc9.umbc.edu>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: schlein@umbc.edu's message of 25 Feb 1996 19:29:49 -0500
-
- In article <4gqutt$i1f@umbc9.umbc.edu>
- schlein@umbc.edu (Jonas J. Schlein) writes:
-
- JJS: |> char name;
- JJS: |> int age, next_age;
- JJS: |>
- JJS: |> printf("%s\n","Please enter your name and age: ");
- JJS: |> scanf("%s%d\n", &name, &age);
- JJS:
- JJS: Why do you use %s when you clearly have 'name' declared as a single
- JJS: char. So either use %c in which case we'll assume you know a lot of people
- JJS: with 1 letter names /* OR */ make your declaration an array of acceptable
-
- A single character name also overflows. %s adds a terminating '\0'.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-